package com.china08.yxyapi.api.manage.edu.platform.schooltuijian;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.china08.yxyapi.api.YxyApiBaseController;
import com.china08.yxyapi.model.YxyApiReqModel;
import com.china08.yxyapi.service.sws.EdbWebGroupService;

@CrossOrigin
@RestController
public class EduSchoolTuiJianUpdRecommendController extends YxyApiBaseController {

    @Autowired
    EdbWebGroupService edbWebGroupService;

    @RequestMapping(value = "/api_yw/manage/edu/platform/schooltuijian/upd/recommend", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public void precess(HttpServletRequest request, HttpServletResponse response, @RequestBody ReqModel reqModel) {
        String schoolId = reqModel.schoolId;
        Integer bureauLevel = reqModel.bureauLevel;
        boolean tuijian = reqModel.tuijian;
        try {
            edbWebGroupService.updRecommend(schoolId, tuijian, bureauLevel);
        } catch (Exception e) {

        }
    }

    public static class ReqModel extends YxyApiReqModel {
        public boolean tuijian;
        public String schoolId;
        public Integer bureauLevel;

        @Override
        public void autoCheck() {
            Assert.isTrue(StringUtils.isNotBlank(schoolId), "未获取当前学校");
            Assert.isTrue(bureauLevel == 0 || bureauLevel == 1 || bureauLevel == 2, "未获取教育局级别");
        }
    }
}
